package com.example.whereismystuff.classes;

import android.content.Context;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase;


public class DatabaseHelperMain extends SQLiteOpenHelper{
	
	private static final String DATABASE_NAME = "Temp Name";
	private static int DATABASE_VERSION = 1;
	
	
	DatabaseHelperMain(Context context){
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}//End constructor

	@Override
	public void onCreate(SQLiteDatabase db){
		//Creates users table with all item attributes plus unique ID
		//(Should be able to store admins as well if they don't have any
		//additional parameters, though that's a quick fix)
		db.execSQL("CREATE TABLE users (id INTEGER, username TEXT," +
				"password TEXT, email TEXT, items TEXT, blocked INT, isAdmin INT)");
		
		//Creates items table with all item attributes plus unique ID
		db.execSQL("CREATE TABLE items (id INTEGER, , isFound INTEGER, claimed INTEGER, reward INTEGER," +
				"name TEXT, description TEXT, city TEXT, state TEXT, zipcode INTEGER, posterID INTEGER," +
				"claimerID INTEGER, loc1 INTEGER, loc2 INTEGER, image BLOB, tags TEXT)");
	}//End method
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		//Drops existing table (If there is one) and replaces it with db
		db.execSQL("DROP TABLE IF EXISTS users");
		db.execSQL("DROP TABLE IF EXISTS items");
		onCreate(db);
		DATABASE_VERSION++;
	}//End method
}//End DatabaseHelper class